//
//  UISearchBar+Additions.m
//  CareGiver
//
//  Created by Guillermo Moral on 9/1/14.
//  Copyright (c) 2014 Humana. All rights reserved.
//

#import "UISearchBar+Additions.h"

@implementation UISearchBar (Additions)

-(void)updateStatus {
    UIView *topView = self.subviews[0];
    for (UIView *subView in topView.subviews) {
        if ([subView isKindOfClass:NSClassFromString(@"UINavigationButton")]){
            UIButton *button = (UIButton*)subView;
            [button setEnabled:YES];
        } else  if ([subView isKindOfClass:NSClassFromString(@"UISearchBarTextField")]) {
            UITextField *searchBar = (UITextField*)subView;
            [searchBar setEnabled:YES];
        }
    }
}

-(void)updateButtonColor:(UIColor*)color {
    UIButton *cancelButton;
    UIView *topView = self.subviews[0];
    for (UIView *subView in topView.subviews) {
        if ( [subView isKindOfClass:NSClassFromString(@"UINavigationButton")]) {
            cancelButton = (UIButton*)subView;
        }
    }
    
    if (cancelButton) {
        [cancelButton setTitleColor:color forState:UIControlStateNormal];
    }
}

@end
